# Maintainer: kpcyrd <kpcyrd[at]archlinux[dot]org>

pkgname=cxxbridge
pkgver=1.0.101
pkgrel=1
pkgdesc='Safe interop between Rust and C++'
url='https://github.com/dtolnay/cxx'
arch=('loong64' 'x86_64')
license=('Apache' 'MIT')
makedepends=('cargo')
options=(!lto)
source=(https://github.com/dtolnay/cxx/archive/${pkgver}/${pkgname}-${pkgver}.tar.gz
        Cargo.lock)
sha256sums=('2f6000d0d011d7d2494a7c5cecd705ae4e838b0db40d0af9069b7aae43a8fe44'
            '08e4c75f06af0f8e67ea3f3d103f5f77e04bae555b443be2c6a2e17a59520d06')
b2sums=('91f01cb775413d89f5b8f4ae2adc49b91da48f47448c78787404274b7ba47e5a2891a440d7a240c652fb427237047841d548e219b35da8863a4a71b92b51b383'
        '0eeaec65da373d54872d8aef78b441e3e2702955ebfc54380d7c3fcd87a7f3ba7c650389eeaf572c291acb90a9f3c7adda5152f602903f52587ceb844be5cc2f')

prepare() {
  cd "cxx-${pkgver}"
  cp ../Cargo.lock .
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

updlockfiles() {
  cd "cxx-${pkgver}"
  rm -f Cargo.lock
  cargo update
  cp Cargo.lock "${outdir}/"
}

build() {
  cd "cxx-${pkgver}/gen/cmd"
  cargo build --frozen --release
}

check() {
  cd "cxx-${pkgver}"
  cargo test --frozen
}

package() {
  cd "cxx-${pkgver}"
  install -Dm 755 target/release/${pkgname} "${pkgdir}/usr/bin/${pkgname}"
  install -Dm 755 include/cxx.h -t "${pkgdir}/usr/share/${pkgname}/"

  install -Dm 644 README.md -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 LICENSE-* -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

# vim: ts=2 sw=2 et:
